<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css"
	href="/ComputerStore/public/css/admin_content.css">
<script type="text/javascript"
	src="/ComputerStore/public/js/jquery-1.6.2.min.js"></script>

<!-- Javascript -->
<script>
	$(document).ready(function() {
		$("#formEdit").css("display", "none");
		$("#formAdd").css("display", "none");
		$("#showList").css("border-style", "inset");

		$("#showForm").click(function() {
			$(this).css("border-style", "inset");
			$("#showList").css("border-style", "outset");
			$("#list").hide("fast");
			$("#formEdit").hide("fast");
			$("#formAdd").show("fast");
			$("#textarea1").val("");
			$("#textarea2").val("");
		});

		$("#showList").click(function() {
			$(this).css("border-style", "inset");
			$("#showForm").css("border-style", "outset");
			$("#formAdd").hide("fast");
			$("#formEdit").hide("fast");
			$("#list").show("fast");
		});
		var valueArray = new Array();

		$("a").click(function() {
			if ($(this).attr("name") == "editFaq") {
				var id = $(this).attr("id");
				$('#' + id + ' td').each(function(index) {
					valueArray[index] = $(this).text();
				});
				$("#textareaQuestion").val(valueArray[4]);
				$("#textareaAnswer").val(valueArray[5]);
				$("#showList").css("border-style", "outset");
				$("#list").hide("fast");
				$("#formEdit").show("fast");
			}
		});
	});
</script>
<meta http-equiv="Content-Type" content="text/html">
<title>Danh sách FAQs</title>
</head>
<body>
	<h1>Quản lý FAQs</h1>
	<div id="options">
		<a id="showList" href="#">&nbsp;&nbsp;&nbsp;Danh sách Faqs
			&nbsp;&nbsp;&nbsp;</a> <a id="showForm" href="#">&nbsp;&nbsp;&nbsp;Thêm
			Faqs&nbsp;&nbsp;&nbsp;</a>
	</div>
	<br />

	<div id="formAdd">
		
		<div class="title">Thêm FAQs</div>
		<div class="content">
			<s:form id="addFaq" action="addFaq" validate="true">
				<div>Thêm Câu Hỏi</div>
				<s:textarea id="textarea1" value="gõ text" theme="simple" cols="74" 
					name="faq.question"></s:textarea>
				<div>Thêm Trả Lời</div>
				<s:textarea id="textarea2" cols="74" theme="simple"
					name="faq.answer"></s:textarea><br/>
				<s:submit id="button" name="submit" theme="simple" value="Thêm mới" />
			</s:form>
		</div>
	</div>
	<div class="title" id="formEdit">
		Sửa đổi thông tin FAQs
		<div class="content">
			<s:form id="editFaq" action="editFaq">
				<div>Thêm Câu Hỏi</div>
				<s:textarea id="textareaQuestion" value="gõ text" theme="simple"
					cols="74" rows="3" name="faq.question"></s:textarea>
				<div>Thêm Trả Lời</div>
				<s:textarea id="textareaAnswer" cols="74" rows="3" theme="simple"
					name="faq.answer"></s:textarea>
				<s:submit id="btnEdit" value="Sửa đổi"></s:submit>
			</s:form>
		</div>
	</div>
	<div id="list">
		<div class="title">List of FAQs</div>
		<div class="content">
			<s:form id="faq">
				<table border="1">
					<tr>
						<td>&nbsp; STT</td>
						<td>&nbsp; Ngày Đăng</td>
						<td>&nbsp; Ngày Sửa Cuối</td>
						<td>&nbsp; Trạng Thái</td>
						<td>&nbsp; Câu Hỏi</td>
						<td>&nbsp; Trả Lời</td>
						<td>&nbsp; Thao Tác</td>
					</tr>
					<s:iterator value="faqList" var="faq" status="itStatus">
						<tr id="<s:property value="id"/>">
							<td align="center"><s:property value="#itStatus.Count" /></td>
							<td><s:property value="dateAdded" /></td>
							<td><s:property value="lastModified" /></td>
							<td align="center"><s:property value="status" /></td>
							<td><s:property value="question" /></td>
							<td><s:property value="answer" /></td>
							<td align="center"><a
								href="deleteFaq?id=<s:property value="id"/>">&nbsp;Xóa&nbsp;</a>-<a
								name="editFaq" id=<s:property value="id"/> href="#">&nbsp;Sửa&nbsp;</a></td>
						</tr>
					</s:iterator>
				</table>


			</s:form>
		</div>
	</div>

</body>
</html>